#include<iostream>
#include<memory>
#include<sys/types.h>
#include<sys/socket.h>
#include <functional> 

#include"serve.hpp"
#include"Route.hpp"
#include "pthreadpool.hpp"
using namespace LogModule;
using namespace PthreadPoolModule;
using task_t=std::function<void()>;
std::string defaultfunc(std::string word)
{
    return word;
}
int main(int argc,char* argv[])
{
    if(argc!=2)
    {
        LOG(LogLevel::ERROR)<<"请输入正确的格式："<<"serve  port ";
        exit(1);
    }
//路由服务
    Route r;
    uint16_t port=std::stoi(argv[1]);
//线程池
    auto pt= Pthreadpool<task_t>::GetInstance();
//UDP_serve
    std::unique_ptr<UdpServe> serve=std::make_unique<UdpServe>(port,[&r,&pt](int sockid,std::string message,InetAddr peer){
        std::cout;
        task_t t=std::bind(&Route::MessageRout,&r,sockid,message,peer);
        pt->Enqueue(t);
    });
    serve->Init();
    serve->Start();
    return 0;
}